package com.minxin.springcloud;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by wangpeng on 2017/3/7.
 */
@RestController
@RefreshScope//Config客户端在服务器参数刷新时，也刷新注入的属性值
public class ProviderController {

    private final Logger logger = LoggerFactory.getLogger(ProviderController.class);

    @Value("${info}")
    String configInfo;

    @RequestMapping("/hello")
    String hello() {
        return "Hello! " + configInfo + "!";
    }

    @RequestMapping(value = "/helloProvider", method = RequestMethod.GET)
    public String test(@RequestParam String str) {
        logger.info("进入生产者服务方法 参数str:{}", str);
        return str;
    }

}
